﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IronCow;

namespace Milkify.Data
{
    public class TaskCreateData : TaskEditData
    {
        public Task Task { get; private set; }
        public TaskList SuggestedTaskList { get; private set; }

        public override TaskList ParentTaskList
        {
            get { return SuggestedTaskList; }
            set { SuggestedTaskList = value; }
        }

        public TaskCreateData(Task task, TaskList suggestedTaskList, IEnumerable<TaskList> taskLists, IEnumerable<string> tags, IEnumerable<Location> locations)
            : base(taskLists, tags, locations)
        {
            Task = task;
            SuggestedTaskList = suggestedTaskList;
        }

        public override string GetTags(string separator)
        {
            return Task.GetTags(separator);
        }

        public override void SetTaskTags(string formattedTags, char[] separators)
        {
            Task.SetTags(formattedTags, separators);
        }

        public override void Commit()
        {
            // This will effectively add the task to a list, 
            // and therefore sync it with the server.
            Task.Parent = SuggestedTaskList;
        }
    }
}
